# coding:utf-8
import requests


class ResponseDemo:
    def _test_response(self):
        """
        rd = ResponseDemo()
        rd._test_response()
        """
        url = 'https://www.baidu.com'
        response = requests.head(url)
        print(response.status_code)  # 状态码
        print(response.url)  # 响应的url
        print(response.request.headers)  # 查看请求头
        print(response.headers)  # 查看响应头
        print(response.content.decode())  # 查看二进制源码
        print(response.encoding)  # 查看str类型的源码
        response.encoding = 'utf-8'
        print(response.text)


if __name__ == '__main__':
    rd = ResponseDemo()
    rd._test_response()
